//
//  MineMesageTableViewCell.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/16.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit
class MineMessageModel: NSObject {
    var type = ""
    var amount = ""
    var timeStr = ""
    var status = ""//根据cash_state判断1提现中 2提现成功3提现失败
    var account = ""//提现账户
    override init() {
        super.init()
    }
    
    init(source : Dictionary<String,Any>) {
        super.init()
        print(source)
        if let typ = source["cash_type"] as? Int{
            if typ == 1 {
                if let accnt = source["cash_account"] as? String {
                    account = accnt
                }
                type = "支付宝"
            }else if typ == 2 {
                if let accnt = source["nick_name"] as? String {
                    account = accnt
                }
                type = "微信"
            }
        }
        if let amnt = source["cash_money"] as? Int {
            amount = NumberToString.intToFloatString(number: amnt, radix: 100)
        }
        if let date = source["create_time"] as? String {
            timeStr = date
        }
        if let stat = source["cash_state"] as? Int {
            if stat == 1 {
                status = "提现中..."
            } else if stat == 2 {
                status = "提现成功"
            } else if stat == 3 {
                status = "提现失败"
            }
        }
    }
}
class MineMessageTableViewCell: UITableViewCell {

    private var titleLbl = UILabel.init()
    private var dateLbl = UILabel.init()
    
    var model = MineMessageModel.init() {
        didSet{
            titleLbl.text = "您申请的" + model.type + "提现金额:" + model.amount + ",提现成功.可进入" + model.type + "查看"
            let size = titleLbl.text!.stringSize(font: titleLbl.font, maxWid: YXDeviceWidth - 134 * YXWidthScale)
            titleLbl.frame = CGRect.init(origin: CGPoint.init(x: 48 * YXWidthScale, y: 40 * YXWidthScale), size: CGSize.init(width: size.width, height: size.height))
            dateLbl.text = model.timeStr
            let size1 = dateLbl.text!.StringSize(font: dateLbl.font)
            dateLbl.frame = CGRect.init(origin: CGPoint.init(x: titleLbl.left(), y: titleLbl.bottom() + 30 * YXHeightScale), size: size1)
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = UIColor.colorWithHexString(hex: "f3f3f5")
        let tray = UIView.init()
        tray.backgroundColor = UIColor.white
        tray.frame = CGRect.init(x: 30 * YXWidthScale, y: 20 * YXHeightScale, width: YXDeviceWidth - 60 * YXWidthScale, height: 196 * YXHeightScale)
        tray.layer.borderColor = UIColor.colorWithHexString(hex: "dfdfdf").cgColor
        tray.layer.borderWidth = YXHeightScale
        tray.layer.cornerRadius = YXButtonCorner
        self.contentView.addSubview(tray)
//        let dot = UIView.init()
//        dot.frame = CGRect.init(origin: CGPoint.init(x: 26 * YXWidthScale, y: 50 * YXHeightScale), size: CGSize.init(width: 12 * YXHeightScale, height: 12 * YXHeightScale))
//        dot.backgroundColor = UIColor.colorWithHexString(hex: "ff2f2b")
//        dot.layer.cornerRadius = 6 * YXHeightScale
//        tray.addSubview(dot)
        
        titleLbl.numberOfLines = 2
        titleLbl.textColor = UIColor.colorWithHexString(hex: "2c2c2c")
        titleLbl.font = UIFont.systemFont(ofSize: 32 * YXWidthScale)
        tray.addSubview(titleLbl)
        
        dateLbl.textColor = UIColor.colorWithHexString(hex: "909090")
        dateLbl.font = UIFont.systemFont(ofSize: 24 * YXWidthScale)
        tray.addSubview(dateLbl)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }

}
